/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-14
 * Time: 15:47
 */
class Student {
    private String name;
    private int age;
    private int score;
    private static String className = "2";
   /* //实例代码块
    {
        this.age = 12;
        this.score = 100;
        this.name = "wangwang";
    }

    //静态代码块
    static {
        className = "2023班";
    }*/

    public Student(String name, int age, int score, String className) {
        this.age = age;
        this.name = name;
        this.score = score;
        Student.className = className;
        System.out.println("这个构造方法执行了..");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public void show() {
        System.out.println("姓名" + this.name + " 年龄"
                + this.age + "成绩" + this.score);

    }

    public static void setClassName(String className) {
        Student.className = className;
    }

    //静态成员方法-->类方法
    public static String getClassName() {

        //不能直接调用，在静态方法中不能直接调用，非静态方法（依赖于对象），要调用则要先实例化！！
        /*show();*/

        Student student = new Student("lisi", 12, 99, "4");
        student.show();
        return className;
    }

    //实例代码块
    {
        System.out.println("实例代码被执行了...");
    }

    //静态代码块
    static {

        System.out.println("这是个静态代码块一般用来初始化局部变量");
    }
}

public class Main {
    public static void main(String[] args) {

        Student student1 = new Student("lisi", 12, 99, "2");
//        System.out.println(student1.getClassName());
    }
}
